<template>
  <div class="boxBody">
    <div class="content">
      <!--左侧-->
      <div class="content-item mr_10">
        <cus-search style="min-width: 600px">
          <cus-search-item>
            <Form ref="formValidateForm" :model="selectForm">
              <FormItem
                class="mr_48 mb_20"
                label="物资名称"
                :label-width="80"
                prop="productName"
              >
                <Input
                  clearable
                  placeholder="请输入物资名称"
                  v-model="selectForm.productName"
                />
              </FormItem>
              <FormItem class="mr_48 mb_20" label="" prop="poinventroyType">
                <Select
                  v-model="selectForm.poinventroyType"
                  @on-change="postApiGoodsPoinventroyReceivepoinventroysApi"
                  placeholder="全部库存"
                  style="width: 200px"
                >
                  <Option
                    v-for="item in poinventroyTypeTree"
                    :value="item.value"
                    :key="item.value"
                    >{{ item.label }}</Option
                  >
                </Select>
              </FormItem>
              <cusButton
                class="ml_20 mr_20 mb_20"
                type="primary"
                @onClick="postApiGoodsPoinventroyReceivepoinventroysApi"
                >查询</cusButton
              >
              <cusButton class="mb_20" type="primary" @onClick="reset()"
                >重置</cusButton
              >
            </Form>
          </cus-search-item>
        </cus-search>
        <cus-card
          style="margin-top: 20px; padding-top: 20px"
          :showTitle="false"
        >
          <cusTable
            border
            :loading="form.loading"
            :columns="columns"
            :data="data"
            :size="vuex_config.tableSize"
            :bottomClass="['cus-page','cus_operBox']"
          >
            <template slot-scope="{ row }" slot="operation">
              <div class="flex">
                <cus-button
                  type="text"
                  size="small"
                  :style="{ color: '#1E6FFF' }"
                  style="padding: 0 5px"
                  @onClick="onAdd(row)"
                >
                  添加领用
                </cus-button>
              </div>
            </template>
          </cusTable>
          <div class="cus_page">
            <cus-page
              :data="pages"
              class="mt_20"
              @pageChange="postApiGoodsPoinventroyReceivepoinventroysApi"
            ></cus-page>
          </div>
        </cus-card>
      </div>
      <!--右侧-->
      <div class="content-item ml_10">
        <cus-search>
          <cus-search-item>
            <Form>
              <FormItem
                class="mr_10 mb_20"
                label="领用单位"
                :label-width="100"
                :rules="[{ required: true, message: '', trigger: 'none' }]"
              >
                <Select
                  placeholder="全部"
                  clearable
                  v-model="rForm.recipientDepartmentId"
                  style="width: 160px"
                >
                  <Option
                    v-for="item in recipientDepartmentTree"
                    :value="item.id"
                    :key="item.id"
                    >{{ item.name }}</Option
                  >
                </Select>
              </FormItem>
              <FormItem
                class="mr_48 mb_20"
                label="领用人"
                :label-width="90"
                :rules="[{ required: true, message: '', trigger: 'none' }]"
              >
                <Input
                  placeholder="请输入领用人"
                  clearable
                  v-model="rForm.recipientBy"
                  style="width: 160px"
                />
              </FormItem>
              <!-- <cusButton class="mb_20" type="primary" @onClick="onImport"
                >导入食谱领用单</cusButton
              > -->
            </Form>
          </cus-search-item>
        </cus-search>
        <cus-card
          style="margin-top: 20px; padding-top: 20px"
          :showTitle="false"
        >
          <cusTable
            border
            :loading="form.loading"
            :columns="columnsList"
            :data="dataList"
            :size="vuex_config.tableSize"
            :bottomClass="['cus-page','cus_operBox']"
          >
            <template slot-scope="{ row }" slot="operation">
              <div class="flex">
                <cus-button
                  type="text"
                  size="small"
                  :style="{ color: '#FF4746' }"
                  style="padding: 0 5px"
                  @onClick="onDelete(row)"
                >
                  <Icon
                    type="ios-trash-outline"
                    size="4"
                    style="margin: 2px 3px 0 0"
                  />
                  <span>删除</span>
                </cus-button>
              </div>
            </template>
          </cusTable>
          <div class="cus_page">
            <cus-page
              :data="page"
              class="mt_20"
              @pageChange="postApiGoodsCreatereceivedtlListApi"
            ></cus-page>
          </div>
        </cus-card>
      </div>
    </div>
    <!--底部提交，返回-->
    <div class="cus_operBox" style="width: calc(100% - 250px)">
      <Button type="success" class="mr_20" @click="onSend">保存</Button>
      <Button type="error" class="mr_20" @click="onReturn">返回</Button>
    </div>
    <!--添加物资弹框-->
    <Modal v-model="wuziModal" title="添加物资" width="470">
      <Form
        ref="formValidate"
        :model="form"
        :label-width="150"
        style="display: flex; justify-content: center"
      >
        <FormItem
          label="领用方式"
        >
          <Select
            size="large"
            placeholder="全部"
            v-model="form.isWeight"
            disabled
            @on-change="recipientsWayChange"
            style="width: 200px"
          >
            <Option
              v-for="item in recipientsWayTree"
              :value="item.value"
              :key="item.value"
              >{{ item.label }}</Option
            >
          </Select>
        </FormItem>
        <FormItem label="计量单位:">
          <Input
            v-model="form.packagingUtil"
            clearable
            disabled
            style="width: 200px"
          ></Input>
        </FormItem>
        <FormItem label="物资名称:">
          <Input
            v-model="form.productName"
            clearable
            disabled
            style="width: 200px"
          ></Input>
        </FormItem>
        <FormItem label="单价(元):">
          <Input
            v-model="form.packagingPrice"
            clearable
            disabled
            style="width: 200px"
          ></Input>
        </FormItem>
        <!-- <FormItem label="包装价格:" v-if="!flag">
          <Input
            v-model="form.packagingPrice"
            clearable
            disabled
            style="width: 200px"
          ></Input>
        </FormItem> -->
        <!-- <FormItem label="库存重量:" v-if="flag">
          <Input
            v-model="form.num"
            clearable
            disabled
            style="width: 200px"
          ></Input>
        </FormItem> -->
        <FormItem label="库存数量:">
          <Input
            v-model="form.packagingQty"
            clearable
            disabled
            style="width: 200px"
          ></Input>
        </FormItem>
        <!-- <FormItem label="已领用未记账重量:" :label-width="150" v-if="flag">
          <Input
            v-model="form.realQuantity"
            clearable
            disabled
            style="width: 200px"
          ></Input>
        </FormItem> -->
        <FormItem label="已领用未记账数量:">
          <Input
            v-model="form.packagingRealQty"
            clearable
            disabled
            style="width: 200px"
          ></Input>
        </FormItem>
        <FormItem label="领用数量:">
          <InputNumber
            :max="10000"
            :min="0"
            :precision ='form.isWeight ? 2 : 0'
            v-model="form.packagingQtyNum"
            :active-change="false"
            style="width: 200px"
          />
        </FormItem>
        <!-- <FormItem label="领用包装数量:">
          <InputNumber
            :max="10000"
            :min="0"
            :precision="0"
            v-model="form.recipientsNum"
            style="width: 200px"
          />
        </FormItem> -->
        <div
          style="
            height: 40px;
            line-height: 40px;
            color: red;
            display: flex;
            justify-content: center;
            margin-top: -30px;
            margin-left: 25px;
          "
        >
          *{{ `可领用数量 (${quantity})` }}
        </div>
        <!-- <div
          v-if="flag"
          style="
            height: 40px;
            line-height: 40px;
            color: red;
            display: flex;
            justify-content: center;
            margin-top: -30px;
            margin-left: 25px;
          "
        >
          *{{ `可领用重量 (${numCalculate})` }}
        </div> -->
      </Form>
      <div slot="footer">
        <slot name="footer">
          <div class="modal-footer">
            <cus-button size="small" class="mr_2" @onClick="onCancel"
              >取消</cus-button
            >
            <cus-button type="primary" size="small" @onClick="onOk"
              >确认</cus-button
            >
          </div>
        </slot>
      </div>
    </Modal>
    <!--导入当日食谱领用单-->
    <Modal v-model="shipuModal" title="导入食谱领用单" width="500">
      <Form
        ref="formValidateShiPu"
        :rules="cookBookFormRule"
        :model="form"
        :label-width="105"
        style="margin: 0 0 -25px 0"
      >
        <FormItem label="当前食谱：" prop="mealPlanId">
          <Select
            size="large"
            placeholder="请选择"
            v-model="form.mealPlanId"
            style="width: 300px"
          >
            <Option
              v-for="item in createreceivedtlTree"
              :value="item.mealPlanId + ''"
              :key="item.mealPlanId"
              >{{ item.name }}</Option
            >
          </Select>
        </FormItem>
        <FormItem label="星期：" prop="week">
          <Select
            size="large"
            placeholder="请选择"
            v-model="form.week"
            style="width: 300px"
          >
            <Option
              v-for="item in mealWeekList"
              :value="item.value"
              :key="item.value"
              >{{ item.label }}</Option
            >
          </Select>
        </FormItem>
        <FormItem label="餐次：" prop="mealTimes">
          <Select
            size="large"
            placeholder="请选择"
            v-model="form.mealTimes"
            style="width: 300px"
          >
            <Option
              v-for="item in mealList"
              :value="item.value"
              :key="item.value"
              >{{ item.label }}</Option
            >
          </Select>
        </FormItem>
      </Form>
      <div slot="footer">
        <slot name="footer">
          <div class="modal-footer">
            <cus-button size="small" class="mr_2" @onClick="shipuModal = false"
              >取消</cus-button
            >
            <cus-button type="primary" size="small" @onClick="submitCookBook"
              >确认</cus-button
            >
          </div>
        </slot>
      </div>
    </Modal>
    <!--食谱餐次所需领用食材-->
    <recipeModal ref="recipeModal"></recipeModal>
  </div>
</template>
<script>
import {
  postApiGoodsPoinventroyReceivepoinventroys,
  postApiGoodsCreatereceivedtlSave,
  postApiGoodsCreatereceivedtlList,
  postApiGoodsCreatereceivedtlDelete,
  postApiFoodBookServiceSelectPresentMealPlan,
  postApiGoodsSelectMealPlanTimesFoodList,
  postApiGoodsReceiveorderSave,
  getDepartmentOfCurrentUnit
} from "@/api/business/manager";

import recipeModal from "./recipeModal.vue";

const form = {
  productName: "", //物资名称
  poinventroyType: "", //库存
  productId: "", //物资id-
  unit: "", //单位-
  stockQty: "", //库存数量
  goodsTypeId: "", //物资种类id
  packagingPrice: "", //价格-
  // packagingQty: 1, //领用数量-
  id: "", //库存 id值
  recipientsWay: "", //领用方式
  packagingUtil: null, //用于添加物资根据规格判断领用方式，除0，1以外其他可选择领用方式
  // packagingPrice: "", //包装价格
  packagingQty: null, //库存数量-
  packagingQtyNum: null, //领用数量
  packagingRealQty: "", //已领用未记账包装数量
  mealPlanId: "", //当日选择食谱id
  week: "", //星期
  mealTimes: "", //餐次 0  早 ，1  中，  2   晚
  loading: false
};
const rForm = {
  productId: "", // 物资id-
  unit: "", // 单位-
  quantityStock: "", // 库存数量
  goodsTypeid: "", // 物资种类id
  packagingPrice: "", // 价格-
  packagingQty: "", // 领用数量-
  poinventroyId: "", // 库存 id值
  recipientBy: "", // 领用人
  recipientDepartmentId: "", // 领用单位id
  loading: false
};
const poinventroyTypeTree = [
  {
    label: "当日入库",
    value: 2
  },
  {
    label: "全部库存",
    value: 0
  }
];
const columns = [
  {
    title: "序号",
    type: "index",
    align: "center",
    width: 70
  },
  {
    title: "物资名称",
    key: "productName",
    minWidth: 135,
    align: "center"
  },
  {
    title: "仓库",
    key: "stockName",
    minWidth: 80,
    align: "center"
  },
  {
    title: "库存数量",
    key: "packagingQty",
    minWidth: 75,
    align: "center"
  },
  {
    title: "计量单位",
    key: "packagingUtil",
    minWidth: 75,
    align: "center"
  },
  // {
  //   title: "库存重量",
  //   key: "num",
  //   minWidth: 105,
  //   align: "center"
  // },
  {
    title: "单位重量(Kg)",
    key: "unitWeight",
    minWidth: 105,
    align: "center"
  },
  {
    title: "单价(元)",
    key: "packagingPrice",
    minWidth: 75,
    align: "center"
  },
  {
    title: "操作",
    fixed: "right", // 右侧固定
    slot: "operation",
    align: "center",
    width: 105
  }
];
const columnsList = [
  {
    title: "序号",
    type: "index",
    align: "center",
    width: 70
  },
  {
    title: "物资名称",
    key: "productName",
    minWidth: 100,
    align: "center"
  },
  {
    title: "仓库",
    key: "stockName",
    minWidth: 80,
    align: "center"
  },
  {
    title: "领用数量",
    key: "packagingQty",
    minWidth: 100,
    align: "center"
  },
  {
    title: "计量单位",
    key: "packagingUtil",
    minWidth: 100,
    align: "center"
  },
  {
    title: "单位重量(Kg)",
    key: "unitWeight",
    minWidth: 105,
    align: "center"
  },
  {
    title: "单价(元)",
    key: "packagingPrice",
    minWidth: 90,
    align: "center"
  },
  {
    title: "金额(元)",
    key: "amount",
    minWidth: 90,
    align: "center"
  },
  {
    title: "操作",
    fixed: "right", // 右侧固定
    slot: "operation",
    align: "center",
    width: 105
  }
];
const recipientsWayTree = [
  {
    label: "按重量",
    value: 1
  },
  {
    label: "按数量",
    // label: "按包装数量",
    value: 0
  }
];
const mealWeekList = [
  {
    value: "one",
    label: "星期一"
  },
  {
    value: "two",
    label: "星期二"
  },
  {
    value: "three",
    label: "星期三"
  },
  {
    value: "four",
    label: "星期四"
  },
  {
    value: "five",
    label: "星期五"
  },
  {
    value: "six",
    label: "星期六"
  },
  {
    value: "seven",
    label: "星期日"
  }
];
const mealList = [
  {
    value: "0",
    label: "早餐"
  },
  {
    value: "1",
    label: "午餐"
  },
  {
    value: "2",
    label: "晚餐"
  },
  {
    value: "3",
    label: "全天"
  }
];
export default {
  components: { recipeModal },
  data() {
    return {
      form: form, // 左侧物资表单
      rForm: rForm, // 右侧表单
      ruleValidate: {}, // rule验证
      selectForm: {
        productName: "", //物资名称
        poinventroyType: 0 //库存
      },
      poinventroyTypeTree: poinventroyTypeTree, //库存select 数据
      columns: columns, // 左侧物资表头
      data: [], // 左侧物资表格列数据
      columnsList: columnsList, // 右侧表头
      dataList: [], // 右侧表格列数据
      wuziModal: false, // 添加物资弹框状态
      recipientsWayTree: recipientsWayTree, // 领用方式Select数据
      shipuModal: false, // 导入当日食谱领用单弹框状态
      createreceivedtlTree: [], // 当日食谱select数据
      mealWeekList: mealWeekList, // 日期Tree数据
      mealList: mealList, // 就餐类型数据
      // flag: true, // 按重量，按包装数量获取显示状态
      recipientDepartmentTree: [], // 领用单位Tree数据
      // 左侧分页
      pages: {
        page: 1,
        pageSize: 10,
        pageTotal: 0
      },
      // 右侧分页
      page: {
        page: 1,
        pageSize: 10,
        pageTotal: 0
      },
      cookBookFormRule: {
        mealPlanId: [
          { required: true, message: "当前食谱必填", trigger: "blur" }
        ],
        week: [{ required: true, message: "星期必填 ", trigger: "blur" }],
        mealTimes: [{ required: true, message: "餐次必填", trigger: "blur" }]
      },
      tableHeight: 0,
      poinventroyType: ""
    };
  },
  mounted() {
    setTimeout(() => {
      this.tableHeight = window.innerHeight - 412; // 表格自适应高度
    }, 100);
    window.addEventListener("resize", this.tableHeightChange, true);
    this.onInit();
  },
  destroyed() {
    window.removeEventListener("resize", this.tableHeightChange, true);
  },
  methods: {
    tableHeightChange() {
      this.tableHeight = 0;
      setTimeout(() => {
        this.tableHeight = window.innerHeight - 412; // 表格自适应高度
      }, 100);
    },
    onInit() {
      this.getDepartmentOfCurrentUnitApi();
      this.postApiGoodsPoinventroyReceivepoinventroysApi();
      this.postApiGoodsCreatereceivedtlListApi();
    },
    // 重置搜索
    reset() {
      this.$refs["formValidateForm"].resetFields();
      this.postApiGoodsPoinventroyReceivepoinventroysApi();
    },
    // 添加物资
    onAdd(v) {
      console.log(v);
      // this.flag = true;
      this.wuziModal = true;
      this.form = JSON.parse(JSON.stringify(v));
      this.form.packagingQtyNum = 0;
      this.form.recipientsWay = this.recipientsWayTree[1].value;
      // if (v.packagingUtil != "公斤" && v.packagingUtil != "斤") {
      //   this.flag = false;
      //   this.form.recipientsWay = this.recipientsWayTree[1].value; //默认按包装数量
      // }
    },
    // 领用方式事件
    recipientsWayChange(v) {
      // if (v == 1) {
      //   this.flag = false;
      // } else {
      //   this.flag = true;
      //   //  this.form.packagingUtil = '公斤';
      // }
    },
    // 正则判断须输入纯数字
    // numberFixedDigit(val) {
    //   // 固定两位小数
    //   let checkPlan = "" + val;
    //   checkPlan = checkPlan
    //     .replace(/[^\d.]/g, "") // 清除“数字”和“.”以外的字符
    //     .replace(/\.{2,}/g, ".") // 只保留第一个. 清除多余的
    //     .replace(/^\./g, "") // 保证第一个为数字而不是.
    //     .replace(".", "$#$")
    //     .replace(/\./g, "")
    //     .replace("$#$", ".");
    //   if (checkPlan.indexOf(".") < 0 && checkPlan !== "") {
    //     // 以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
    //     checkPlan = parseFloat(checkPlan) + "";
    //   } else if (checkPlan.indexOf(".") >= 0) {
    //     checkPlan = checkPlan.replace(/^()*(\d+)\.(\d\d).*$/, "$1$2.$3"); // 只能输入两个小数
    //   } else if (checkPlan < 0) {
    //     checkPlan = 0;
    //   }
    //   this.$nextTick(() => {
    //     console.log(checkPlan);
    //     this.form.packagingQtyNum = checkPlan * 1;
    //   });
    //   return checkPlan;
    // },
    // 删除领用单
    onDelete(row) {
      this.$cu
        .dialog({
          params: row
        })
        .then(({ id }) => {
          this.postApiGoodsCreatereceivedtlDeleteApi(id);
        });
    },
    // 导入当日食谱领用单
    onImport() {
      this.shipuModal = true;
      this.$refs["formValidateShiPu"].resetFields();
      this.postApiFoodBookServiceSelectPresentMealPlanApi();
    },
    onOk() {
      console.log('zzzz',this.form.packagingUtil);
      console.log(this.form.packagingUtil == '斤')
      if(!['公斤','斤'].includes(this.form.packagingUtil)) {
        console.log(this.form.packagingUtil);
       
        if(String(this.form.packagingQtyNum).indexOf('.') > -1) {
          // console.log(String(this.form.packagingQtyNum).indexOf('.'))
          this.$Message.info("请输入正整数");
          return;
        }
      }
      if (this.form.packagingQtyNum != 0) {
        this.postApiGoodsCreatereceivedtlSaveApi();
      } else {
        this.$Message.info("请输入可领用数量");
      }
    },
    onCancel() {
      this.wuziModal = false;
    },
    // 提交
    onSend() {
      if (this.rForm.recipientDepartmentId == "") {
        this.$Message.info("领用单位不能为空");
      } else if (this.rForm.recipientBy == "") {
        this.$Message.info("领用人不能为空");
      } else if (this.dataList.length > 0) {
        this.postApiGoodsReceiveorderSaveApi();
      } else {
        console.log(this.dataList.length < 0);
        this.$Message.info("请添加领用数据");
      }
    },
    // 返回
    onReturn() {
      this.$router.push({
        path: "/view/kitchenMaterial/materialReceipt"
      });
    },
    // 获取物资领用单-----------------------------------接口
    postApiGoodsPoinventroyReceivepoinventroysApi() {
      return new Promise(resolve => {
        let params = {
          productName: this.selectForm.productName, //物资名称
          poinventroyType: this.selectForm.poinventroyType, //库存
          current: this.pages.page,
          size: this.pages.pageSize
        };
        postApiGoodsPoinventroyReceivepoinventroys(params).then(res => {
          this.form.loading = false;
          if (res.retCode == 2000) {
            this.data = res.data.records;
            this.pages.pageTotal = res.data.total;
          }
          resolve();
        });
      });
    },
    // 添加物资领用--------------------------接口
    postApiGoodsCreatereceivedtlSaveApi() {
      return new Promise(resolve => {
        let params = {
          productId: this.form.productId, //物资id
          // unit: this.form.packagingUtil, //单位
          // quantityStock: this.form.stockQty, //库存数量
          // goodsTypeid: this.form.goodsTypeId, //物资种类id
          // packagingPrice: this.form.packagingPrice, //价格
          packagingQty: this.form.packagingQtyNum, //领用数量
          poinventroyId: this.form.id, //库存 id值
          // recipientsWay: this.form.recipientsWay //领用方式
        };
        postApiGoodsCreatereceivedtlSave(params).then(res => {
          if (res.retCode == 2000) {
            this.$Message.success(res.retMsg);
            this.onInit();
            this.wuziModal = false;
          } else {
            console.log(222);
            // this.$Message.error(res.retMsg)
          }
          resolve();
        });
      });
    },
    // 获取物料领用单添加列表---------------接口
    postApiGoodsCreatereceivedtlListApi() {
      this.rForm.loading = true;
      return new Promise(resolve => {
        let params = {
          current: this.page.page,
          size: this.page.pageSize
        };
        postApiGoodsCreatereceivedtlList(params).then(res => {
          this.rForm.loading = false;
          if (res.retCode == 2000) {
            this.dataList = res.data.records;
            this.page.pageTotal = res.data.total;
          } else {
            this.rForm.loading = false;
          }
          resolve();
        });
      });
    },
    // 删除物料领用单-------------------------接口
    postApiGoodsCreatereceivedtlDeleteApi(id) {
      return new Promise(resolve => {
        postApiGoodsCreatereceivedtlDelete({
          id: id
        }).then(res => {
          if (res.retCode == 2000) {
            this.$Message.success(res.retMsg);
            this.onInit();
          }
          resolve();
        });
      });
    },
    // 获取当日食谱----------------------------------接口
    postApiFoodBookServiceSelectPresentMealPlanApi() {
      return new Promise(resolve => {
        postApiFoodBookServiceSelectPresentMealPlan().then(res => {
          if (res.retCode == 2000) {
            this.createreceivedtlTree = res.data;
            console.log("-------------", res);
          }
          resolve();
        });
      });
    },
    submitCookBook() {
      this.$refs.formValidateShiPu.validate(valid => {
        if (valid) {
          this.postApiGoodsSelectMealPlanTimesFoodListApi();
        }
      });
    },
    // 食谱餐次所需领用食材--------------------------接口
    postApiGoodsSelectMealPlanTimesFoodListApi() {
      return new Promise(resolve => {
        let params = {
          mealPlanId: Number(this.form.mealPlanId), //食谱id
          mealTimes: this.form.mealTimes, //就餐类型
          week: this.form.week //星期
        };
        postApiGoodsSelectMealPlanTimesFoodList(params).then(res => {
          if (res.retCode == 2000) {
            this.$Message.success(res.retMsg);
            this.$refs["recipeModal"].show(res);
            this.$refs["recipeModal"].formAll.mealPlanId = this.$cu.deepClone(
              this.form.mealPlanId
            );
            this.$refs["recipeModal"].formAll.mealTimes = this.$cu.deepClone(
              this.form.mealTimes
            );
            this.$refs["recipeModal"].formAll.week = this.$cu.deepClone(
              this.form.week
            );
            this.shipuModal = false;
          }
          resolve();
        });
      });
    },
    // 提交保存物资领用单------------------------接口
    postApiGoodsReceiveorderSaveApi() {
      this.$cu.showLoading();
      return new Promise(resolve => {
        let params = {
          recipientBy: this.rForm.recipientBy,
          recipientDepartmentId: this.rForm.recipientDepartmentId
        };
        postApiGoodsReceiveorderSave(params).then(res => {
          this.$cu.hideLoading();
          if (res.retCode == 2000) {
            this.$Message.success(res.retMsg);
            this.onInit();
          } else {
            this.$cu.hideLoading();
          }
          resolve();
        });
      });
    },
    // 查询下级单位-------------------------接口
    getDepartmentOfCurrentUnitApi() {
      return new Promise(resolve => {
        getDepartmentOfCurrentUnit().then(res => {
          if (res.retCode == 2000) {
            this.recipientDepartmentTree = res.data;
          }
          resolve();
        });
      });
    }
  },
  computed: {
    numCalculate() {
      let num = parseFloat((this.form.num - this.form.realQuantity).toFixed(2));
      return num;
    },
    quantity() {
      let num  = this.form.packagingQty - this.form.packagingRealQty
        num = num < 0 ? 0 : num
      return this.form.isWeight == 1 ? num.toFixed(2) : num.toFixed(0)
    }
  }
};
</script>

<style lang="less" scoped>
.boxBody {
  height: 100%;
  width: 100%;
  .content {
    width: 100%;
    height: 93%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    &-item {
      height: 100%;
      overflow: auto;
      flex: 1;
    }
  }
}
</style>
